//
//  YTUserSettingController.m
//  YUNT
//
//  Created by haha on 2017/11/12.
//  Copyright © 2017年 梁炜东. All rights reserved.
//

#import "YTUserSettingController.h"

@interface YTUserSettingSwitchCell ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UISwitch *switchButton;

@end

@implementation YTUserSettingSwitchCell

@end

@interface YTUserSettingLabelCell ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *subtitleLabel;

@end

@implementation YTUserSettingLabelCell

@end

@interface YTUserSettingController ()

@property (weak, nonatomic) IBOutlet UITableView *mainTabelView;

@end

@implementation YTUserSettingController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self.navigationController.navigationBar setHidden:NO];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = Language(@"设置");
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.view.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:244/255.0 alpha:1.0];
    
    self.mainTabelView.tableFooterView = [[UIView alloc] init];
    
    self.mainTabelView.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:244/255.0 alpha:1.0];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0)
    {
       
    }
    else if (indexPath.row == 1)
    {
        
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section
{
    return 0.0f;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section
{
    return 0.0f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0)
    {
        YTUserSettingSwitchCell *cell = [self.mainTabelView dequeueReusableCellWithIdentifier:@"setting_switch" forIndexPath:indexPath];
        
        cell.titleLabel.text = Language(@"手机相册权限设置");
        
        cell.switchButton.on = YES;
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
    }
    else if (indexPath.row == 1)
    {
        YTUserSettingLabelCell *cell = [self.mainTabelView dequeueReusableCellWithIdentifier:@"setting_label" forIndexPath:indexPath];
        
        cell.titleLabel.text = Language(@"清除缓存");
        
        cell.subtitleLabel.text = @"0.0M";
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
    }
    return nil;
}

- (IBAction)switchButtonAction:(UISwitch *)sender
{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:Language(@"此操作要求访问照片，请前往设置-隐私-照片进行设置") preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:Language(@"确定") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    
    [alert addAction:cancel];
    
    [self presentViewController:alert animated:YES completion:nil];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
